<template>
	<view class="quan">
		<form @submit="formSubmit" @reset="formReset">
		<view class="content">
			<view @click="openSheet()" class="tou">
				<view class="header">银行</view>
				<input  class="header-one" name="bank" placeholder="请填写开户行" />
			</view>
			<view class="tiao"></view>
			<view class="zhongbu">
				<view class="zhong">持卡人</view>
				<input class="num" name="name" placeholder="请填写持卡人姓名"  />
			</view>
			<view class="tiao-one"></view>
			<view class="kahao">
				<view class="kahao-one">卡号</view>
				<input type="number" class="shuzi" name="num" placeholder="请填写卡号" />
			</view>
			<view class="tiao-two"></view>
		</view>

		<!-- 变现按钮 -->
		<view class="btn">
			<view class="pert">
				<view class="moren">是否设为默认</view>
				<switch class="danxuan" :checked="checkdata" color="#fa436a" @change="switchChange" />
			</view>
			<button class="primary" type="primary" form-type="submit">确认添加</button>
		</view>
		</form>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isFiexd: false,
			look: true,
			default:'1',
			show_yzm: true,
			seconde: '60',
			checkdata:false,
		};
	},
	onLoad() {
		uni.request({
			url:'http://tuiguang.yiyunoto.com/api/member/addmybank',
			header:{authtoken:this.$store.state.token},
			success:(res)=>{
				console.log("11请求成功",res)
				this.yh_new=res.data.data
			},
			fail:(res)=>{
				console.log("请求失败",res)
			}
		})
	},
	methods: {
		openSheet() {
			this.isFiexd = true;
		},
		closeSheet() {
			this.isFiexd = false;
		},
		switchChange(e) {
			console.log(e.detail.value)
			this.checkdata = e.detail.value;
			if(e.detail.value== true){
				this.default=2
				console.log("默认安妮1",this.default)
			}else{
				this.default=1
				console.log("默认安妮2",this.default)
			}
		},
		formSubmit: function(e) {
			console.log(e.detail.value)
			this.yhxx = e.detail.value
			var content = this.yhxx
			uni.request({
				url: 'http://tuiguang.yiyunoto.com/api/member/addmybank',
				header:{authtoken:this.$store.state.token},
				method: 'POST',
				data: {
					bankname: content.bank,
					holder: content.name,
					cardnumber:content.num,
					default:this.default,
				},
				success: (res) => {
					console.log("提现成功", res)
					uni.showToast({
						title: res.data.msg,
					})
					if (res.data.msg == "添加成功") {
						uni.redirectTo({
							url: '../list_bank/list_bank'
						})
					}
					console.log(res.data.data);
				},
				fail: (res) => {
					console.log("登录失败", res)
					uni.showToast({
						title: res.data.msg
					})
				}
			});
		},
		yzm: function() {
			console.log('获取验证码', this.tel);
			const requestTask = uni.request({
				url: 'http://tuiguang.yiyunoto.com/api/login/smsSend',
				method: 'POST',
				data: {
					phone: this.tel
				},
				success: res => {
					uni.showToast({
						title: res.data.msg
					});
					if (res.data.msg == '短信验证码发送成功') {
						(this.show_yzm = false),
							setInterval(() => {
								--this.seconde;
							}, 1000);
						setTimeout(() => {
							this.show_yzm = true;
							this.seconde=60;
						}, 60000);
					}
				}
			});
		}
	}
};
</script>

<style>
.sheet {
	width: 100%;
	height: 100%;
	position: fixed;
	top: 120%;
	left: 0upx;
	bottom: 0upx;
	right: 0upx;
	background: rgba(0, 0, 0, 0.3);
	z-index: 10000;
}
/* 显示时候的动画默认0.5s */
.sheetView {
	width: 100%;
	height: 0upx;
	position: absolute;
	bottom: 0upx;
	background: white;
	z-index: 10001;
	transition: all 0.5s;
}
.sheetShow {
	top: 0upx !important;
}
/* 关闭时的动画，时间自己可以设置0.5s*/
.sheeHide {
	top: 120% !important;
	transition: all 0.5s;
}
/* 项目需求根据设计稿要展示的高度,超出这个高度就自动滚动*/
.sheetView_active {
	height: 942upx;
}
.quan {
	width: 100%;
	height: 100vh;
	background: #f7f7f7;
	
}
.content {
	border-top: 2upx solid #e6e6e6;
	width: 100%;
	height:350upx;
	background: rgba(255, 255, 255, 1);
}
.tou {
	width: 100%;
	height: 112upx;
	margin-bottom: 0.5upx;
}
.header {
	float: left;
	font-size: 30upx;
	font-family: PingFangSC-Regular, PingFangSC;

	color: rgba(81, 81, 81, 1);
	padding-left: 50upx;
	padding-top: 35upx;
}
.header-one {
	float: left;
	font-size: 30upx;
	font-family: PingFangSC-Regular, PingFangSC;
	padding-left: 80upx;
	padding-top: 35upx;
}
.tiao {
	background: #e6e6e6;
	width: 100%;
	height: 1upx;
	margin-top: 0upx;
}
.zhongbu {
	width: 100%;
	height: 112upx;
}
.zhong {
	float: left;
	font-size: 30upx;
	font-family: PingFangSC-Regular, PingFangSC;
	color: rgba(81, 81, 81, 1);
	padding-left: 50upx;
	padding-top: 35upx;
}
.num {
	float: left;
	font-size: 30upx;
	font-family: PingFangSC-Regular, PingFangSC;
	padding-left: 50upx;
	padding-top: 35upx;
}
.tiao-one {
	width: 100%;
	height: 1upx;
	background: #e6e6e6;
	padding-top: 1upx;
}
.kahao {
	width: 100%;
	height: 112upx;
}
.kahao-one {
	float: left;
	font-size: 30upx;
	font-family: PingFangSC-Regular, PingFangSC;
	color: rgba(81, 81, 81, 1);
	padding-left: 50upx;
	padding-top: 35upx;
}
.shuzi {
	float: left;
	font-size: 30upx;
	font-family: PingFangSC-Regular, PingFangSC;
	padding-left: 80upx;
	padding-top: 35upx;
}
.tiao-two {
	width: 100%;
	height: 1upx;
	background: #e6e6e6;
	padding-top: 1upx;
}
.top {
	width: 100%;
	height: 130upx;
	text-align: center;
	background: #fdefd4;
	color: #5f321f;
	font-size: 28upx;
	padding-top: 20upx;
	box-sizing: border-box;
}
.top1 {
	width: 100%;
	padding-bottom: 12upx;
	text-align: center;
}
.cash_in_yzm {
	width: 100%;
	height: 100upx;
	padding: 30upx 30upx;
	margin-top: 18upx;
	box-sizing: border-box;
	background: #ffffff;
}
.yzm_text {
	width: 90upx;
	float: left;
	font-size: 30upx;
	font-family: PingFangSC-Regular, PingFangSC;
	color: rgba(81, 81, 81, 1);
	padding-left: 26upx;
}
.yzm {
	float: left;
	width: 149upx;
	font-size: 30upx;
	font-family: PingFangSC-Regular, PingFangSC;
	color: rgba(184, 184, 184, 1);
	padding-left: 47upx;
}
.yzm_btn {
	width: 25%;
	font-size: 26upx;
	text-align: right;
	float: right;
	color: blue;
	padding-top: 6upx;
}
.yzm_btn2 {
	width: 25%;
	font-size: 26upx;
	text-align: right;
	float: right;
	color: #dbdada;
	
}
.class {
	width: 750upx;
	height: 112upx;
	background: rgba(255, 255, 255, 1);
}
.pert {
	width: 750upx;
	height: 112upx;
	background: rgba(255, 255, 255, 1);
	margin-top: 55upx;
}
.moren {
	font-size: 38upx;
    font-family: PingFangSC-Regular, PingFangSC;
    color: rgba(113, 113, 113, 1);
    margin-left: 56upx;
    float: left;
    margin-top: 28upx;
}
.danxuan {
	float: right;
    border-radius: 20upx;
    matop: 0upx;
    width: 20%;
    margin-top: 24upx;
}
.primary {
	width: 680upx;
	height: 98upx;
	background: rgba(81, 134, 238, 1);
	border-radius: 10upx;
	margin-top: 80upx;
}
</style>
